package fr.grassaud.hmvc.sample;

import fr.grassaud.hmvc.component.Model;
import fr.grassaud.hmvc.event.HMVCEvent;
import fr.grassaud.hmvc.event.OnInit;
import fr.grassaud.hmvc.session.HMVCSession;
import fr.grassaud.hmvc.session.SessionContext;


@Model(controlledBy=SampleController.class)
public class SampleModel {

    
    private String data;
    
    private String init = "NO";
    
    private String viewEvent = "NO";
    
    private String modelEvent = "NO";
    
    private String controllerEvent = "NO";
    
    @SessionContext
    private HMVCSession session;

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }
    
    
    @OnInit
    private void init() {
	init = "OK";
    }
    public String getInit() {
	return this.init;
    }

    public String getViewEvent() {
        return viewEvent;
    }

    public void setViewEvent(String viewEvent) {
        this.viewEvent = viewEvent;
    }

    public String getModelEvent() {
        return modelEvent;
    }

    public void setModelEvent(String modelEvent) {
        this.modelEvent = modelEvent;
    }

    public String getControllerEvent() {
        return controllerEvent;
    }

    public void setControllerEvent(String controllerEvent) {
        this.controllerEvent = controllerEvent;
    }
    
    
    public void sendEvent() {
	session.sendModelEvent(this,new HMVCEvent("load",this));
    }
    
    
}
